#-*- coding:utf-8 -*-
import paramiko
import os

# pythonp
def ssh_scp_put(hostname, port, user, password,localFile, remoteFile):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(hostname=hostname, port=port, username=user, password=password)
    sftp = ssh.open_sftp()
    for root, dirs, files in os.walk(localFile):
        print '----',root,'-----'
        print  files
        for fname in files:
            full_name = os.path.join(root, fname)
            sftp.put(full_name, os.path.join(remoteFile, fname))
    sftp.close()
    ssh.close()

if __name__ == '__main__':
    localFile = '/home/hh/desk/collectData/'
    #remoteFile = '/home/secsmarts/a/aa'
    remoteFile = '/Users/wuyou/Desktop/datafromUbuntu/'
    hostname = '192.168.1.47'
    port = 22
    user = 'wuyou'
    password ='     '
    ssh_scp_put(hostname=hostname,port=port, user=user,password=password,localFile=localFile,remoteFile=remoteFile)
    print 'sss'

    #t = paramiko.Transport((hostname, port))
    #t.connect(username=user, password=password)
    #sftp = paramiko.SFTPClient.from_transport(t)
    #sftp.put('/home/hh/desk/normal_data', remoteFile)
